package com.earl.dialogprogress;

import android.content.DialogInterface;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ProgressBar;
import android.view.View;
import android.view.View.OnClickListener;

public class MainActivity extends AppCompatActivity {
    private ProgressBar fristBar = null;
    private ProgressBar secondBar=null;
    private Button mybutton=null;
    private int i=0;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        fristBar=(ProgressBar)findViewById(R.id.fristBar);
        secondBar=(ProgressBar)findViewById(R.id.secondBar);
        mybutton=(Button)findViewById(R.id.muButton);
        mybutton.setOnClickListener(new ButtonListener());
    }

    class ButtonListener implements OnClickListener{
        public void onClick(View v){
            if(i==0){
                fristBar.setVisibility(View.VISIBLE);
                secondBar.setVisibility(View.VISIBLE);
                fristBar.setMax(150);
            }
            else if(i<fristBar.getMax())
            {
                fristBar.setProgress(i);
                fristBar.setSecondaryProgress(i+10);
            }
            else{

                fristBar.setVisibility(View.GONE);
                secondBar.setVisibility(View.GONE);
            }

            i=i+10;
            if(i>150)
            {
                i=0;
            }
        }
    }




}
